package com.fudan.cfg.trans;

import java.util.List;
import java.util.Map;

import com.fudan.cfg.base.TransDef;
import com.fudan.run.ctx.annotation.TransAdapter;

@TransAdapter("build_node")
public class BuildNodeTransDef extends TransDef{

	private String key;
	private String nodeName;//节点名称，如果以%开头则取记录中对应key的值
	private String parentNode;
	private List<String> extractToRoot;
	
	public BuildNodeTransDef(String name, String type,String target) {
		super(name, type,target);
	}

	@Override
	public TransDef build(Map<String, Object> configuration) {
		this.nodeName = (String) configuration.get("node_name");
		this.setParentNode((String) configuration.getOrDefault("parent_node", "root"));
		this.extractToRoot = (List<String>) configuration.get("extract_to_root");
		this.key = (String) configuration.get("key");
		if(key == null) {
			throw new RuntimeException("build-node 中key不能为null");
		}
		return this;
	}
	public String getNodeName() {
		return nodeName;
	}
	public void setNodeName(String nodeName) {
		this.nodeName = nodeName;
	}
	public List<String> getExtractToRoot() {
		return extractToRoot;
	}
	public void setExtractToRoot(List<String> extractToRoot) {
		this.extractToRoot = extractToRoot;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getParentNode() {
		return parentNode;
	}

	public void setParentNode(String parentNode) {
		this.parentNode = parentNode;
	}

}
